//
//  CustomLunchView.m
//  HuoBao
//
//  Created by 于会海 on 15/12/22.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "CustomLunchView.h"

@implementation CustomLunchView
//#define GetFinalresult(a,b) (isIphone4or5?a:b)
//#define GetIPhone4result(a,b) (IsIphone4?a:b)
#define GetFinalResult(x,y,z,r) (IsIphone4?x:(IsIphone6P?r:(IsIphone5?y:z)))

#define GetFinalImage(stringA,stringB,stringC,stringD) (IsIphone4?StringFormat(stringA):(IsIphone6P?StringFormat(stringD):(IsIphone5?StringFormat(stringB):StringFormat(stringC))))
#define StringFormat(a) [NSString stringWithFormat:@"%@",a]

- (instancetype)init{
    self = [super init];
    return self;
}

- (void)showLanchView{
    UIImageView *lanchImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    lanchImageView.image = [UIImage imageNamed:@"lanch_bg"];
    [self addSubview:lanchImageView];
    
    UIImage* image = [UIImage imageNamed:GetFinalImage(@"logo_4",@"logo_5",@"logo", @"logo")];
    UIImageView* logImage = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - image.size.width)/2, GetFinalResult(163, 163, 204, SCREEN_HEIGHT*204/667), image.size.width, image.size.height)];
    logImage.image = image;
    [self addSubview:logImage];
    
    UIImageView* startImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    startImageView.image = [UIImage imageNamed:GetFinalImage(@"start_lanch_4",@"start_lanch_5",@"start_lanch_6", @"start_lanch_6")];
    [self addSubview:startImageView];
    
    [[UIApplication sharedApplication].keyWindow addSubview:self];
    
    [UIView animateWithDuration:1.5 animations:^{
        startImageView.alpha = 0.5;
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:3 animations:^{
            startImageView.alpha = 0;
            logImage.alpha = 0.0;
            lanchImageView.alpha = 0.0;
            lanchImageView.frame = CGRectMake(-60, -85, SCREEN_WIDTH+100, SCREEN_HEIGHT+150);
        } completion:^(BOOL finished) {
            [self removeFromSuperview];
        }];
    }];
}

- (void)stopLanchView{

}

@end
